<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:c="http://java.sun.com/jsp/jstl/core"
	xmlns:fn="http://java.sun.com/jsp/jstl/functions"
	xmlns:p="http://primefaces.org/ui">

<h:form id="formAthleteAvailability" prependId="false" style="height:100%">
	<div align="center" style="height:90%" >	

		<p:dataTable id="tblAvailability" value="#{athleteBean.athlete.schedules}" var="schedule" paginator="true"  style="width:100%" sortBy="name" sortOrder="descending"
			paginatorAlwaysVisible="false"  paginatorPosition="bottom" rows="8" emptyMessage="#{msgs.NoResults}">
			<p:columnGroup type="header" >  
				<p:row>
					<p:column colspan="10" style="text-align:center;">
						<f:facet name="header">
							<h:outputText value="#{msgs.AthleteModalitys}" />
						</f:facet>
					</p:column>
				</p:row>
				<p:row>
					<p:column	colspan="1">
						<f:facet name="header">
							<h:outputText value="#{msgs.Name}"/>
						</f:facet>
					</p:column>
					<p:column	colspan="1">
						<f:facet name="header" >
							<h:outputText value="#{msgs.Monday}" 	style="white-space:nowrap"/>
						</f:facet>
					</p:column>
					<p:column	colspan="1" >
						<f:facet name="header">
							<h:outputText value="#{msgs.Tuesday}" 	style="white-space:nowrap"/>
						</f:facet>
					</p:column>
					<p:column	colspan="1" >
						<f:facet name="header">
							<h:outputText value="#{msgs.Wednesday}" style="white-space:nowrap"/>
						</f:facet>
					</p:column>
					<p:column	colspan="1" >
						<f:facet name="header">
							<h:outputText value="#{msgs.Thursday}" style="white-space:nowrap"/>
						</f:facet>
					</p:column>
					<p:column	colspan="1" >
						<f:facet name="header">
							<h:outputText value="#{msgs.Friday} " style="white-space:nowrap"/>
						</f:facet>
					</p:column>
					<p:column	colspan="1" >
						<f:facet name="header">
							<h:outputText value="#{msgs.Saturday}" style="white-space:nowrap"/>
						</f:facet>
					</p:column>
					<p:column	colspan="1" >
						<f:facet name="header">
							<h:outputText value="#{msgs.Sunday}" style="white-space:nowrap"/>
						</f:facet>
					</p:column>
				</p:row>	
			</p:columnGroup>
			
			<p:column colspan="1" headerText="#{msgs.Name}" >
				<h:outputText value="#{schedule.modality.name}" />
			</p:column>
			<p:column colspan="1"  style="text-align:center">
				<p:commandButton value="#{msgs.Availability}" icon="#{not empty schedule.availability.monday ?'led_on':'led_off'}" update=":dlgAvailability" oncomplete="wdlgAvailability.show()">
					<f:setPropertyActionListener target="#{athleteBean.selScheduleDay}" value="#{schedule.availability.monday}"/>
				</p:commandButton>
			</p:column>
			<p:column colspan="1"  style="text-align:center">
				<p:commandButton value="#{msgs.Availability}" icon="#{not empty schedule.availability.tuesday ?'led_on':'led_off'}" update=":dlgAvailability" oncomplete="wdlgAvailability.show()">
					<f:setPropertyActionListener target="#{athleteBean.selScheduleDay}" value="#{schedule.availability.tuesday}"/>
				</p:commandButton>
			</p:column>
			<p:column colspan="1"  style="text-align:center">
				<p:commandButton value="#{msgs.Availability}" icon="#{not empty schedule.availability.wednesday ?'led_on':'led_off'}" update=":dlgAvailability" oncomplete="wdlgAvailability.show()">
					<f:setPropertyActionListener target="#{athleteBean.selScheduleDay}" value="#{schedule.availability.wednesday}"/>
				</p:commandButton>
			</p:column>
			<p:column colspan="1"  style="text-align:center">
				<p:commandButton value="#{msgs.Availability}" icon="#{not empty schedule.availability.thursday ?'led_on':'led_off'}" update=":dlgAvailability" oncomplete="wdlgAvailability.show()">
					<f:setPropertyActionListener target="#{athleteBean.selScheduleDay}" value="#{schedule.availability.thursday}"/>
				</p:commandButton>
			</p:column>
			<p:column colspan="1"  style="text-align:center">
				<p:commandButton value="#{msgs.Availability}" icon="#{not empty schedule.availability.friday ?'led_on':'led_off'}" update=":dlgAvailability" oncomplete="wdlgAvailability.show()">
					<f:setPropertyActionListener target="#{athleteBean.selScheduleDay}" value="#{schedule.availability.friday}"/>
				</p:commandButton>
			</p:column>
			<p:column colspan="1"  style="text-align:center">
				<p:commandButton value="#{msgs.Availability}" icon="#{not empty schedule.availability.saturday ?'led_on':'led_off'}" update=":dlgAvailability" oncomplete="wdlgAvailability.show()">
					<f:setPropertyActionListener target="#{athleteBean.selScheduleDay}" value="#{schedule.availability.saturday}"/>
				</p:commandButton>
			</p:column>
			<p:column colspan="1"  style="text-align:center">
				<p:commandButton value="#{msgs.Availability}" icon="#{not empty schedule.availability.sunday ?'led_on':'led_off'}" update=":dlgAvailability" oncomplete="wdlgAvailability.show()">
					<f:setPropertyActionListener target="#{athleteBean.selScheduleDay}" value="#{schedule.availability.sunday}"/>
				</p:commandButton>
			</p:column>

	        <p:summaryRow >  
	            <p:column colspan="1" style="text-align:right">  
	                #{msgs.TimeAvailable} 
	            </p:column>  
	            <p:column colspan="1" >  
					#{schedule.availability.mondayTotalTime}
	            </p:column>  
	            <p:column colspan="1" >  
					#{schedule.availability.tuesdayTotalTime}
	            </p:column>  
	            <p:column colspan="1" >  
					#{schedule.availability.wednesdayTotalTime}
	            </p:column>  
	            <p:column colspan="1" >  
					#{schedule.availability.thursdayTotalTime}
	            </p:column>  
	            <p:column colspan="1" >  
					#{schedule.availability.fridayTotalTime}
	            </p:column>  
	            <p:column colspan="1" >  
					#{schedule.availability.saturdayTotalTime}
	            </p:column>  
	            <p:column colspan="1" >  
					#{schedule.availability.sundayTotalTime}
	            </p:column>  
	        </p:summaryRow>  
			<p:columnGroup type="footer" >  
				<p:row>
					<p:column colspan="8" style="text-align:center;">
						<f:facet name="footer">
							<h:outputText value="#{msgs.WeektrainingTime} = #{athleteBean.sumAllIntervals}"/>
						</f:facet>
					</p:column>
				</p:row>
			</p:columnGroup>
		</p:dataTable>

	</div>
		<div align="left"   >
			<p:commandButton  value="#{msgs.Save}"		action="#{athleteBean.saveAthlete}"		
				ajax="true"	update=":growl"		icon="ui-icon-disk"	rendered="#{athleteBean.athlete.id != null}" />
			<p:commandButton  value="#{msgs.Create}"	action="#{athleteBean.createAthlete}"	
				ajax="true"	update=":growl,:content"		icon="ui-icon-document"	rendered="#{athleteBean.athlete.id == null}" />
			<p:spacer width="50px"/>	
			<p:commandButton  value="#{msgs.Cancel}"	action="#{athleteBean.cancelChange}"	icon="ui-icon-cancel"/>
		</div>
</h:form>
</html>